<?php
/**
 * 首页控制器
 */
class IndexController extends CommonController{
	/**
	 * 默认显示首页
	 */
	public function index(){
		//如果缓存失效了******
		if(!$this->is_cached()){
			//处理分类
			$cateData = M()->query("SELECT * FROM hd_category WHERE pid=0");
			//处理压入子集
			foreach ($cateData as $k => $v) {
				$cateData[$k]['son'] = M()->query("SELECT * FROM hd_category WHERE pid={$v['cid']}");
			}
	        //p($cateData);die;
			$this->assign('cateData',$cateData);
			
			if(isset($_SESSION['uid'])){
				$uid=$_SESSION['uid'];
				$yhCate=M()->query("SELECT * FROM hd_user WHERE uid={$uid}");
				$answer=$yhCate[0]['answer'];
				$accept=$yhCate[0]['accept'];
				if($answer!=0){
					$take_c=round($accept/$answer*100,2).'%';
					
					$this->assign('take_c',$take_c);
				}else{
					$take_c=0;
					$this->assign('take_c',$take_c);
				}
				$this->assign("yhCate",$yhCate);
			}
			
			$this->topCate();
            //历史回答问题最多的人
			$this->answerCate();
			//后盾问答助人光荣榜
			$this->acceptCate();
            //高分悬赏的问题
            $this->rewardCate();
			//处理待解决的问题
			$this->solveCate();
            //本日回答问题最多的人
            $this->todayCate();
			//累计提问数量
			$this->wenCate();
			//上传图像
			$this->face();
			
		}
		
		
		
		
		
		$this->display();
	}
}

?>